package com.diy.sigmund.diycommon.designpatterns.factorymethod.pizza2;

import java.util.Objects;

/**
 * @author ylm-sigmund
 * @since 2022/2/8 15:02
 */
public class NYPizzaStore extends PizzaStore {

    @Override
    protected Pizza createPizza(String item) {
        Pizza pizza = null;
        // 纽约点会用到纽约pizza原料工厂
        PizzaIngredientFactory pizzaIngredientFactory = new NYPizzaIngredientFactory();
        // 对于每一种pizza，传入所需的工厂，来实例化对应的实例
        if (Objects.equals("cheese", item)) {
            pizza = new CheesePizza(pizzaIngredientFactory);
            pizza.setName("New York Style Cheese Pizza");
        } else if (Objects.equals("veggie", item)) {
            pizza = new VeggiePizza(pizzaIngredientFactory);
            pizza.setName("New York Style Veggie Pizza");
        } else if (Objects.equals("clam", item)) {
            pizza = new ClamPizza(pizzaIngredientFactory);
            pizza.setName("New York Style Clam Pizza");
        }else if (Objects.equals("pepperoni", item)) {
            pizza = new PepperoniPizza(pizzaIngredientFactory);
            pizza.setName("New York Style Pepperoni Pizza");
        }
        return pizza;
    }
}
